// 基本get查询
const myGetBySkip = (collection, pageNum, pageSize) => {
  wx.showLoading({
    title: '加载中',
  })
  if (pageSize > 20) {
    pageSize = 20
  }
  const db = wx.cloud.database();
  return new Promise((resolve, reject) => {
    db.collection(collection).orderBy('create_at', 'desc').skip(pageNum).limit(pageSize).get().then(res => {
      console.log(res)
      wx.hideLoading({
        success: (res) => {},
      })
      resolve([res.data, pageNum, pageSize])
    }).catch(err => {
      console.error(err)
      wx.hideLoading({
        success: (res) => {},
      })
      reject([], pageNum, pageSize)
    })
  })
}

module.exports = {
  myGetBySkip
}